<%@page import="sys.wx.xy.XY"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/jspf/must/basePath.jspf" %>
<%    if (null == session.getAttribute(XY.SESSION_LOGIN)) {
        response.sendRedirect(basePath + "FWYLogin.jsp");
        return;
    }
%>
<%@page import="weixinkeji.dev.dc.base.scheme.promotions.cache.PromotionConfigControl"%>

<!--后台UI组件Start-->
<%--<%@include file="/WEB-INF/jspf/zj/ligerui/LigerUI.jspf" %>--%>
<%--<%@include file="/WEB-INF/jspf/zj/ligerui/LigerUI_form.jspf" %>--%>

<!--后台UI组件End-->
<!DOCTYPE html>
<html>
    <head>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>开单</title>
        <script src="zj/jq/jquery-1.11.3.min.js"></script>
        <%@include file="/WEB-INF/jspf/zj/uikit/uikit.jspf" %>
        <%@include file="/WEB-INF/jspf/zj/uikit/sticky.jspf" %>
        <!--        <link rel="stylesheet" href="zj/uikit/css/uikit.gradient.min.css" />
                <script src="zj/uikit/js/uikit.min.js"></script>
                <link rel="stylesheet" href="zj/uikit/css/components/sticky.min.css" />
                <script src="zj/uikit/js/components/sticky.min.js"></script> -->
        <script type="text/javascript" src="dc_manager/base/refectory/lookup/refectoryLookUp.js"></script>
        <script>
            $(function() {
                getMyKDList();
                selectKD_NOWSelect();
            });
            function getMyKDList() {
                $.post("view/buy/order/fwy/s/selectMJZ.imy", {}, function(data) {
                    if (null != data) {
                        var str = "";
                        for (var i = 0; i < data.length; i++) {
                            str = str + tableTR_Date(
                                    data[i].order_code
                                    , getOrder_sort(data[i].order_sort)
                                    , data[i].room_code
                                    , data[i].order_time
                                    , data[i].user_name //+ "(" + data[i].user_account + ")"
                                    , data[i].order_id
                                    );
                        }
                        $("#viewKDList").html(str);
                    }
                    function tableTR_Date(order_code, order_sort, room_code, order_time, user_name, order_id) {
                        var str = "<tr>"
                                + "<td class=\"uk-text-middle uk-text-left\"><a href=\"#showFWYOrderData\" data-uk-modal onclick=\"selectKD_ListSelect('" + order_id + "')\">" + order_code + "</a></td>"
                                + "<td class=\"uk-text-middle uk-text-left\">" + order_sort + "</td>"
                                + "<td class=\"uk-text-middle uk-text-left\">" + room_code + "</td>"
                                + "<td class=\"uk-text-middle uk-text-left\">" + order_time + "</td>"
                                + "<td class=\"uk-text-middle uk-text-left\">" + user_name + "</td>"
                                + "<td class=\"uk-text-middle\">"
                                + "<div onclick=\"dellKD('" + order_id + "')\" class=\"uk-text-middle uk-text-center uk-button-danger\" style=\"float:left;width:50%;\">删除</div>"
                                + "<div onclick=\"selectKD('" + order_id + "')\" class=\"uk-text-middle uk-text-center uk-button-primary\" style=\"float:left;width:50%;\">选择</div>"
                                + "</td>"
                                + "</tr>";
                        return str;
                    }
                }, "json");
            }

            function kd() {
                $.post("view/buy/order/fwy/a/add.imy", {refectory_code: $("#KD_rom_code").val()}, function(data) {
                    if (data.length == 26) {
                        selectKD(data);
                        getMyKDList();
                    } else {
                        UIkit.notify(data, {timeout: 2000, status: 'warning'});
                    }
                }, "text");
            }

            function userInput(i) {
                var x = $("#KD_rom_code").val();
                $("#KD_rom_code").val(x + "" + i);
            }
            function toEmptyUserInput() {
                $("#KD_rom_code").val("");
            }
            function selectKD(id) {
                $.post("view/buy/order/fwy/kd/set/order.imy", {order_id: id}, function(data) {
                    if (data.statusCode == 200) {
                        selectKD_NOWSelect();
                    } else {
                        UIkit.notify(data.message, {timeout: 2000, status: 'warning'});
                    }
                }, "json");
            }
            function dellKD(id) {
                $.post("view/buy/order/fwy/kd/d/dell.imy", {order_id: id}, function(data) {
                    if (data.statusCode == 200) {
                        selectKD_NOWSelect();
                        getMyKDList();
                    } else {
                        UIkit.notify(data.message, {timeout: 2000, status: 'warning'});
                    }
                }, "json");
            }
            function selectKD_NOWSelect() {
                $.post("view/buy/order/fwy/kd/select/order.imy", {}, function(data) {
                    if (null != data.order_code && data.order_code != "") {
                        UIkit.notify(data.room_code + "餐点，" + data.order_code + "订单被选择", {timeout: 2000, status: 'success'});
                    }
                    $("#DIV_KDS_CODE").html(null == data.order_code ? "" : data.order_code);
                    $("#DIV_KDS_ROOM").html(null == data.room_code ? "" : data.room_code + "(" + data.room_name + ")");
                    $("#DIV_KDS_TIME").html(null == data.order_time ? "" : data.order_time);
                    $("#DIV_KDS_SUM").html(null == data.order_sumprice ? "" : data.order_sumprice);
                    $("#DIV_KDS_SORT").html(getOrder_sort(data.order_sort));
                }, "json");
            }
            function getOrder_sort(sort) {
                sort = null == sort ? "" : sort;
                if (sort == "0") {
                    return "待付";
                }
                if (sort == "1") {
                    return "已付";
                }
                if (sort == "2") {
                    return "开立"
                }
                return "";
            }
        </script>

    </head>
    <body>
        <div class="uk-width-1" style="margin-top: 15px;margin-bottom: 40px;">
            <nav class="uk-navbar" data-uk-sticky>
                <a class="uk-navbar-brand uk-hidden-small" href="http://imyweb.org"
                   title="IMY框架是一款开源免费的高效高速小巧强大的WEB框架!如果您需要为此产品进行二次开发，您将会需要用到这IMY框架！"
                   target="_blank"
                   >IMY框架</a>
                <div class="uk-container uk-container-center">
                    <ul class="uk-navbar-nav">
                        <li><a href="dc_view/buy/fwy/xd_food.jsp">点餐</a></li>
                        <!--<li><a href="dc_view/buy/fwy/xd_combo.jsp">套餐</a></li>-->
                        <!--<li><a class="uk-button-primary" href="#showFWYCar" data-uk-modal onclick="selectKD_NOWSelect()"><div style="float:left">购物车</div></a></li>-->
                        <li class="uk-active"><a href="dc_view/buy/fwy/kd.jsp">开单</a></li>
                        
                        <li style="text-align: right"><a href="user/fwy/out.imy">登出</a></li>
                    </ul>
                </div>
            </nav>
        </div>
        <div class="uk-margin uk-grid">
            <div class="uk-width-2-3 uk-overflow-container">
                <table class="uk-table uk-table-hover uk-table-condensed">
                    <thead>
                        <tr>
                            <th>单号</th><th>状态</th><th>房间</th><th>开单时间</th><th>开单人</th><th>选择</th>
                        </tr>
                    </thead>
                    <tbody id="viewKDList">

                    </tbody>
                </table>
            </div>
            <div class="uk-width-1-3" style="background-color: #f6eaf7">
                <div class="uk-panel " data-uk-sticky="{boundary}" style="overflow: auto;min-height: 400px;">
                    <div style="margin-top: 50px;">
                        <!--<div><input type="text" name="refectory_id" id="refectory_id2" /></div>-->
                        <div><input type="text" id="KD_rom_code" /></div>
                        <div><button class="uk-button-large" onclick="userInput('1');">1</button><button class="uk-button-large" onclick="userInput('2');">2</button><button class="uk-button-large" onclick="userInput('3');">3</button></div>
                        <div><button class="uk-button-large" onclick="userInput('4');">4</button><button class="uk-button-large" onclick="userInput('5');">5</button><button class="uk-button-large" onclick="userInput('6');">6</button></div>
                        <div><button class="uk-button-large" onclick="userInput('7');">7</button><button class="uk-button-large" onclick="userInput('8');">8</button><button class="uk-button-large" onclick="userInput('9');">9</button><button class="uk-button-large"onclick="toEmptyUserInput()"><div style="color: #0077dd">清空输入</div></button></div>
                        <div><button class="uk-button-large" onclick="userInput('0');">0</button><button class="uk-button-large" onclick="userInput('0');">0</button><button class="uk-button-large" onclick="userInput('0');">0</button><button class="uk-button-large"onclick="kd()"><div style="color: #0077dd">确认开单</div></button></div>
                    </div>
                    <div>
                        <table class="uk-table uk-table-hover uk-table-condensed">
                            <tr><td>单号</td><td><div id="DIV_KDS_CODE"></div></td></tr>
                            <tr><td>房间</td><td><div id="DIV_KDS_ROOM"></div></td></tr>
                            <tr><td>时间</td><td><div id="DIV_KDS_TIME"></div></td></tr>
                            <tr><td>金额</td><td><div id="DIV_KDS_SUM"></div></td></tr>
                            <tr><td>状态</td><td id="DIV_KDS_SORT"><div ></div></td></tr>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div id="DivID_showMenu" style="float:right; margin-left: 8px;font-size:9px;">

    </div>
    <%@include file="/WEB-INF/jspf/dc/fwy/KD.jspf" %>
</body>
</html>
